.PHONY: docker
docker:
	# 删除上次编译的文件
	@rm microbook || true
	# 运行go mod tidy,防止依赖不同步
	@go mod tidy
	# 指定编译在ARM架构的linux系统上可运行的可执行文件 文件名为microbook
	@GOOS=linux GOARCH=arm go build -tags=k8s -o microbook .
	# 删除上次生成的docker镜像
	@docker rmi -f microbook:latest
	# 生成docker镜像
	@docker build . -t microbook:latest


.PHONY: mock
mock:
	@#mockgen -source=./internal/repository/code.go -package=repomocks -destination=./internal/repository/mocks/code_gen.go
	@mockgen -source=./internal/service/user.go -package=svcmocks -destination=./internal/service/mocks/user_gen.go
	@mockgen -source=./internal/service/code.go -package=svcmocks -destination=./internal/service/mocks/code_gen.go
	@mockgen -source=./internal/repository/user.go -package=repomocks -destination=./internal/repository/mocks/user_gen.go
	@mockgen -source=./internal/repository/code.go -package=repomocks -destination=./internal/repository/mocks/code_gen.go
	@mockgen -source=./internal/repository/cache/code.go -package=cachemocks -destination=./internal/repository/cache/mocks/code_gen.go
	@mockgen -source=./internal/repository/cache/user.go -package=cachemocks -destination=./internal/repository/cache/mocks/user_gen.go
	@mockgen -source=./internal/repository/dao/user.go -package=daomocks -destination=./internal/repository/dao/mocks/user_gen.go
	@mockgen -source=./internal/repository/dao/article/reader.go -package=daomocks -destination=./internal/repository/dao/mocks/article/reader_gen.go
	@mockgen -source=./internal/repository/dao/article/author.go -package=daomocks -destination=./internal/repository/dao/mocks/article/author_gen.go
	# mock mod文件内的某个依赖包 github.com/redis/go-redis/v9 下的Cmdable
	@mockgen -package=redismocks -destination=./internal/repository/cache/mocks/redis/redis_cmd_gen.go github.com/redis/go-redis/v9 Cmdable
	@go	mod	tidy

.PHONY: grpc
grpc:
	@buf generate api/proto
